﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HomeWork8
{
    public partial class Form1 : Form
    {
        public String a;
        public String b;
        public String c;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            label.Text+= button.Text;
            if (a ==null)
            {
                a = button.Text;
            }
            else b = button.Text;
        }

        private void ac_Click(object sender, EventArgs e)
        {
            label.Text = null;
            a =null;
            b = null;
        }

        private void caculate_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            label.Text += "=";
            if (c == "+")
            {
                label.Text += (Convert.ToInt32(a) + Convert.ToInt32(b)).ToString();
            }
            else if (c == "-")
            {
                label.Text += (Convert.ToInt32(a) - Convert.ToInt32(b)).ToString();
            }
            else if (c == "*") {
                label.Text += (Convert.ToInt32(a)* Convert.ToInt32(b)).ToString();
            }
            else if (c == "/")
            {
                label.Text += (Convert.ToInt32(a) / Convert.ToDouble(b)).ToString();
            }
        }

        private void divi_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;
            label.Text += button.Text;
            c = button.Text;
        }
    }
}
